<?php

class View_Php{
    var $tplFile;
    function View_Php($tplFile = '')    {
        if(!empty($tplFile))
            $this -> tplFile =  "{$tplFile}";
    }
    /**
     * 返回待输出的view内容
     */
    function fetch($tplFile = ''){
        if(!empty($tplFile))
            $this -> tplFile =  "{$tplFile}";

        ob_start();
        //模板中直接使用的对象
        $response =& Loader::lib('output');

        if(file_exists(APPBASE.'Views/'.$this->tplFile))
            include_once(APPBASE.'Views/'.$this -> tplFile);
        else 
            showError(__T("TplFile doesn't exist!"));
            
        $content = ob_get_clean();
        return $content;
    }
    /**
     * 输出到浏览器
     */
    function display($tplFile = ''){
        if(!empty($tplFile))
            $this -> tplFile =  "{$tplFile}";

        echo $this -> fetch();
    }
}
?>